home *** CD-ROM | disk | FTP | other *** search
/ Freelog 46 / Freelog046.iso / Alu / Celestia / Win32LoresTex / celestia-lores-win32-1.3.0.exe / {app} / shaders / bumpdiffuse.vp < prev    next >
Text File  |  2003-03-05  |  2KB  |  49 lines

  1. !!VP1.0
  2.  
  3. # Compute the surface space light vectors for diffuse bump mapping
  4.  
  5. # c[0]..c[3] contains the concatenation of the modelview and projection matrices.
  6. # c[4]..c[7] contains the inverse transpose of the modelview
  7. # c[15] contains the eye position in object space
  8. # c[16] contains the light direction in object space
  9. # c[17] contains H, the normalized sum of the eye and light direction
  10. # c[20] contains the light color * object color
  11. # c[32] contains the ambient light color * object color
  12. # c[33] contains the haze color
  13. # c[40] contains (0, 1, 0.5, specPower)
  14. # v[6] contains the tangent vector
  15.  
  16. # Transform the vertex by the modelview matrix
  17. DP4   o[HPOS].x, c[0], v[OPOS];
  18. DP4   o[HPOS].y, c[1], v[OPOS];
  19. DP4   o[HPOS].z, c[2], v[OPOS];
  20. DP4   o[HPOS].w, c[3], v[OPOS];
  21.  
  22. MOV   R1, v[NRML];
  23. MOV   R2, v[6];
  24.  
  25. # Compute the binormal--cross product of normal and tangent
  26. MUL   R3, R1.zxyw, R2.yzxw;
  27. MAD   R3, R1.yzxw, R2.zxyw, -R3;
  28.  
  29. # Assume that the tangent and normal are orthonormal; otherwise
  30. # we need to normalize R3
  31. #DP3   R0.w, R3, R3;
  32. #RSQ   R0.w, R0.w;
  33. #MUL   R3.xyz, R3, R0.w;
  34.  
  35. # Transform the light direction from object space into surface space
  36. DP3   R0.x, R2, c[16];
  37. DP3   R0.y, R3, c[16];
  38. DP3   R0.z, R1, c[16];
  39. # Compress the light direction to fit in the primary color and output it
  40. MOV   R5, c[40];
  41. MAD   o[COL0], R0, R5.z, R5.z;
  42.  
  43. # Output the texture coordinates.  Use different coordinates for
  44. # the decal (texture 0) and the bump map (texture 1)
  45. MOV   o[TEX0], v[TEX0];
  46. MOV   o[TEX1], v[TEX1];
  47.  
  48. END
  49.